package cn.easyutil.project.demo.controller;

import cn.easyutil.project.base.util.JsonUtil;
import cn.easyutil.project.base.util.StringUtil;
import cn.easyutil.project.demo.bean.UserBean;
import cn.easyutil.project.demo.service.UserService;
import cn.easyutil.project.web.util.RequestPool;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/apis")
public class EnableController {

    @Autowired
    private UserService userService;

    @GetMapping("10001")
    public UserBean get(UserBean bean){
        return userService.get(bean);
    }

    @GetMapping("10002")
    public void update(UserBean bean){
        userService.update(bean);
    }


    @GetMapping("10003")
    public List<UserBean> list(){
        return userService.listPage(new UserBean());
    }

    @GetMapping("10004")
    public void add(UserBean user){
        userService.add(user);
    }

    @GetMapping("10005")
    public List<UserBean> test(UserBean user){
       return userService.test(user);
    }

    @PostMapping("20001")
    public void body1(@RequestBody UserBean user){
        RequestPool.setAESKey("ptNadF6LoBRwGwFD");
        RequestPool.setUserId(1L);
        System.out.println(user);
    }

    @PostMapping("s-20001")
    public void body2(@RequestBody UserBean user){
        System.out.println(JsonUtil.beanToJson(user));
    }

}
